FROM php:7.3-fpm

# 添加源
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
ADD sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
        wget \
        vim \
        supervisor \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libxml2-dev \
        openssl \
        libssl-dev \
        procps \
        libevent-dev \
        zip
RUN docker-php-ext-install -j$(nproc)  gd iconv json bcmath fileinfo mysqli pdo pdo_mysql xml ctype sockets pcntl posix
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

COPY redis-4.2.0.tgz /home
RUN pecl install /home/redis-4.2.0.tgz && \
        docker-php-ext-enable redis && \
        rm /home/redis-4.2.0.tgz


#更新pecl源
RUN pecl channel-update https://pecl.php.net/channel.xml
# xdebug
COPY xdebug-2.8.0beta1.tgz /home
RUN pecl install /home/xdebug-2.8.0beta1.tgz && \
        docker-php-ext-enable xdebug && \
        rm /home/xdebug-2.8.0beta1.tgz

# swoole
COPY swoole-4.4.15.tgz /home
RUN pecl install /home/swoole-4.4.15.tgz && \
        docker-php-ext-enable swoole && \
        rm /home/swoole-4.4.15.tgz
# RUN pecl install swoole


# mongodb
# COPY mongodb-1.5.3.tgz /home
# RUN pecl install /home/mongodb-1.5.3.tgz && \
#         docker-php-ext-enable mongodb && \
#         rm /home/mongodb-1.5.3.tgz

# opcache
RUN docker-php-ext-install opcache
#COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini

#composer安装
RUN wget https://mirrors.aliyun.com/composer/composer.phar -O /usr/local/bin/composer && chmod a+x /usr/local/bin/composer  && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# USER root

# 清理
RUN apt-get clean && \
        rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
        rm /var/log/lastlog /var/log/faillog

RUN usermod -u 1000 www-data

RUN mkdir -p /var/logs/php/slow.log

WORKDIR /var/www

CMD ["php-fpm"]
# EXPOSE 9001